package com.bocaizp.operation.config;


import com.bocaizp.common.properties.AliOssProperties;
import com.bocaizp.common.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Author : huang jie
 * Date : 2024/4/4 16:54
 **/
@Configuration//声明该类是一个配置类
@Slf4j
public class OssConfiguration {

	@Bean
	@ConditionalOnMissingBean//当Spring容器中没有这中Bean的时候再去创建
	public AliOssUtil aliOssUtil(AliOssProperties aliOssProperties){
		log.info("开始创建阿里云文件上传工具：{}",aliOssProperties);
		return new AliOssUtil(aliOssProperties.getEndpoint(),
					aliOssProperties.getAccessKeyId(),
					aliOssProperties.getAccessKeySecret(),
					aliOssProperties.getBucketName());
	}


}
